﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="MatStockOutRate.aspx.cs"
    Inherits="MatStockOutRate" %>

<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>商品上周出库及时率</title>
    <script src="../js/extTools.js" type="text/javascript"></script>
    <script src="../js/jquery/jquery-1.8.1.min.js" type="text/javascript"></script>
    <script src="../js/jquery/jquery.iDialog.js" dialog-theme="default" type="text/javascript"></script>
    <script src="../js/config.js" type="text/javascript"></script>
    <style>
        .x-grid-row-over .x-grid-cell-inner
        {
            font-weight: bold;
        }
        .x-column-header-inner
        {
            background: #E7EBEF url(./../images/header.png) repeat-x 0 0;
        }
    </style>
    <script>
        $(function () {
            $('#btn_findshop').click(function () {
                getshop($("#txt_shopname").val());
            });
            $('#chkclear').click(function () {
                $('#shop-list input[type="checkbox"]').each(function () {
                    if ($(this).attr('checked') == true) {
                        $(this).click();
                    }
                });
                $('#select-shop').text('');
                $('#txt_shop').val('');
            });
        });
        function showshop() {
            //alert(App.selectshop.getValue());
            if (App.selectshop.getValue() == "") {
                getshop("");
            }
            $.dialog({
                lock: true,
                fixed: true,
                title: '选择店铺',
                width: 800,
                btn: {
                    ok: {
                        val: '确定',
                        type: 'blue',
                        click: function (btn) {
                            var shop = $("#select_shop").text();
                            App.selectshop.setValue($("#txt_shop").val());
                        }
                    },
                    cancle: {
                        val: '取消',
                        type: 'red'
                    }
                },
                content: document.getElementById("my-shop")
            });

        }
        function getshop(val) {
            $.post(url_path + "/MrjControler.aspx",
                { aciton: 'lodshoplist', shopname: val },
                    function (data) {
                        var html = "";
                        var msg = $.trim(data);
                        if (msg == "NO_DATA") {
                            html = "<tr><td>没有数据！</td></tr>"
                        } else {
                            var orderObj = JSON.parse(msg);
                            for (var i = 0; i < orderObj.length; i++) {
                                html += '<div style ="float:left; width:240px;"><input type="checkbox" name="' + orderObj[i].shopname + '" value="' + orderObj[i].shopid + '">' +
                                '<label>' + orderObj[i].shopname + '</label></div>';
                            }
                        }
                        $("#shop-list").html(html);
                        //$('#select_shop').text("");
                        $('#shop-list input[type="checkbox"]').each(function () {
                            $(this).click(function () {
                                var val = $('#select_shop').text();
                                var val2 = $('#txt_shop').val();
                                var chkVal = $(this).val();
                                var chkName = $(this).attr('name');

                                if ($(this).attr('checked') == "checked") {
                                    $('#select_shop').text(val + chkVal + ',');
                                    $('#txt_shop').val(val2 + chkName + ',');
                                }
                                else {
                                    var result = val.replace(new RegExp(chkVal + ',', 'gm'), '');
                                    $('#select_shop').text(result);
                                    //$('#txt_shop').val(val2.replace(chkName + ',', ''));
                                    $('#txt_shop').val(val2.replace(new RegExp(chkName + ',', 'gm'), ''));
                                }
                            })
                        });
                    });
        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <ext:ResourceManager ID="ResourceManager1" runat="server" Theme="Neptune" />
        <ext:Hidden ID="FormatType" runat="server" />
        <ext:Hidden ID="hd_mrjshopid" runat="server" />
        <ext:Viewport ID="Viewport1" runat="server">
            <LayoutConfig>
                <ext:HBoxLayoutConfig Align="Stretch" />
            </LayoutConfig>
            <Defaults>
                <ext:Parameter Name="margin" Value="2 0" Mode="Value" />
            </Defaults>
            <Items>
                <ext:TabPanel ID="TabPanel1" runat="server" Flex="1">
                    <TopBar>
                        <ext:Toolbar ID="Toolbar1" runat="server" Layout="ColumnLayout">
                            <Items>
                                <ext:DateField runat="server" ID="txtbdate" LabelWidth="100" FieldLabel="开始日期" Width="200" />
                                <ext:DateField runat="server" ID="txtedate" LabelWidth="100" FieldLabel="结束日期" Width="200" />
                                <ext:MultiCombo runat="server" ID="txtStock" FieldLabel="仓库" DisplayField="StockName"
                                            ValueField="StockID">
                                            <Store>
                                                <ext:Store runat="server" ID="st_Stock">
                                                    <Model>
                                                        <ext:Model ID="Model2" runat="server">
                                                            <Fields>
                                                                <ext:ModelField Name="StockID" />
                                                                <ext:ModelField Name="StockName" />
                                                            </Fields>
                                                        </ext:Model>
                                                    </Model>
                                                </ext:Store>
                                            </Store>
                                        </ext:MultiCombo>
                                <ext:TextField runat="server"  FieldLabel="货号" EmptyText="输入货号" ID="txtmat" />
                                <ext:Button ID="Button1" runat="server" Text="查询" OnDirectClick="BtnQureyUser" UI="Info"
                                    Icon="Find">
                                    <DirectEvents>
                                        <Click>
                                            <EventMask ShowMask="true" Msg="加载中...">
                                            </EventMask>
                                        </Click>
                                    </DirectEvents>
                                </ext:Button>
                            </Items>
                        </ext:Toolbar>
                    </TopBar>
                    <Items>
                        <ext:GridPanel ID="GridPanel1" runat="server" Title="商品上周出库及时率" TitleAlign="Left"
                            Height="500">
                            <TopBar>
                                <ext:Toolbar runat="server">
                                    <Items>
                                        <ext:Label ID="Label7" runat="server" Text="操作提示：。" StyleSpec="color:red;" Visible="false" />
                                    </Items>
                                </ext:Toolbar>
                            </TopBar>
                            <Store>
                                <ext:Store ID="Store1" runat="server" PageSize="500" OnReadData="RefreshDataSet"
                                    OnSubmitData="Store1_Submit">
                                    <Model>
                                        <ext:Model ID="Model1" runat="server">
                                            <Fields>
                                                <ext:ModelField Name="品类" ServerMapping="MaterialShortName" />
                                                <ext:ModelField Name="仓库" ServerMapping="StockName" />
                                                <ext:ModelField Name="实际入库SKC" ServerMapping="RealSKUQty" />
                                                <ext:ModelField Name="实际入库数量" ServerMapping="RealInQty" />
                                                <ext:ModelField Name="实际入库金额" ServerMapping="RealInAmt" />
                                                <ext:ModelField Name="出库SKC" ServerMapping="SKUOutQty" />
                                                <ext:ModelField Name="出库数量" ServerMapping="OutQty" />
                                                <ext:ModelField Name="出库金额" ServerMapping="OutAmt" />
                                                <ext:ModelField Name="交叉SKC" ServerMapping="SKUQty" />
                                                <ext:ModelField Name="交叉数量" ServerMapping="InQty" />
                                                <ext:ModelField Name="交叉金额" ServerMapping="InAmt" />
                                                <ext:ModelField Name="未出库SKC" ServerMapping="DiffSKU" />
                                                <ext:ModelField Name="未出库数量" ServerMapping="DiffQty" />
                                                <ext:ModelField Name="未出库金额" ServerMapping="DiffAmt" />
                                            </Fields>
                                        </ext:Model>
                                    </Model>
                                </ext:Store>
                            </Store>
                            <ColumnModel>
                                <Columns>
                                    <ext:RowNumbererColumn ID="RowNumbererColumn1" runat="server" />
                                    <ext:Column ID="Column49" runat="server" Text="品类" DataIndex="品类" Width="80" Locked="true"/>
                                    <ext:Column ID="Column1" runat="server" Text="仓库" DataIndex="仓库" Width="150" Locked="true" />
                                    <ext:Column ID="Column2" runat="server" Text="上周实际入库" Width="100">
                                        <Columns>
                                            <ext:Column ID="Column7" runat="server" Text="SCK" DataIndex="实际入库SKC" Width="100" />
                                            <ext:Column ID="Column8" runat="server" Text="数量" DataIndex="实际入库数量" Width="100" />
                                            <ext:Column ID="Column9" runat="server" Text="金额" DataIndex="实际入库金额" Width="100" />
                                        </Columns>
                                    </ext:Column>
                                    <ext:Column ID="Column3" runat="server" Text="上周实际出库" Width="100">
                                        <Columns>
                                            <ext:Column ID="Column10" runat="server" Text="上周出库总计" Width="100">
                                                <Columns>
                                                    <ext:Column ID="Column12" runat="server" Text="SCK" DataIndex="出库SKC" Width="100" />
                                                    <ext:Column ID="Column13" runat="server" Text="数量" DataIndex="出库数量" Width="100" />
                                                    <ext:Column ID="Column14" runat="server" Text="金额" DataIndex="出库金额" Width="100" />
                                                </Columns>
                                            </ext:Column>
                                            <ext:Column ID="Column11" runat="server" Text="上周入库" Width="100">
                                                <Columns>
                                                    <ext:Column ID="Column15" runat="server" Text="SCK" DataIndex="交叉SKC" Width="100" />
                                                    <ext:Column ID="Column16" runat="server" Text="数量" DataIndex="交叉数量" Width="100" />
                                                    <ext:Column ID="Column17" runat="server" Text="金额" DataIndex="交叉金额" Width="100" />
                                                </Columns>
                                            </ext:Column>
                                        </Columns>
                                    </ext:Column>
                                    <ext:Column ID="Column4" runat="server" Text="上周入库但未出库" Width="100">
                                        <Columns>
                                            <ext:Column ID="Column18" runat="server" Text="SCK" DataIndex="未出库SKC" Width="100" />
                                            <ext:Column ID="Column19" runat="server" Text="数量" DataIndex="未出库数量" Width="100" />
                                            <ext:Column ID="Column20" runat="server" Text="金额" DataIndex="未出库金额" Width="100" />
                                        </Columns>
                                    </ext:Column>
                                </Columns>
                            </ColumnModel>
                            <BottomBar>
                                <ext:PagingToolbar ID="PagingToolbar1" runat="server">
                                    <Items>
                                        <ext:Label ID="Label1" runat="server" Text="每页显示:" />
                                        <ext:ToolbarSpacer ID="ToolbarSpacer1" runat="server" Width="10" />
                                        <ext:ComboBox ID="ComboBox1" runat="server" Width="80">
                                            <Items>
                                                <ext:ListItem Text="500" />
                                            </Items>
                                            <SelectedItems>
                                                <ext:ListItem Value="500" />
                                            </SelectedItems>
                                            <Listeners>
                                                <Select Handler="#{GridPanel1}.store.pageSize = parseInt(this.getValue(), 10); #{GridPanel1}.store.reload();" />
                                            </Listeners>
                                        </ext:ComboBox>
                                        <ext:Button ID="Button2" runat="server" Text="导出Excel" Icon="PageExcel">
                                            <Listeners>
                                                <Click Handler="exportData('xls');" />
                                            </Listeners>
                                        </ext:Button>
                                    </Items>
                                    <Plugins>
                                        <ext:ProgressBarPager ID="ProgressBarPager1" runat="server" />
                                    </Plugins>
                                </ext:PagingToolbar>
                            </BottomBar>
                        </ext:GridPanel>
                    </Items>
                </ext:TabPanel>
            </Items>
        </ext:Viewport>
    </div>
    <div id="my-shop" style="display: none;">
        <div style="padding: 3px;">
            <label runat="server" id="select_shop" style="display: none;">
            </label>
            已选择店铺：
            <textarea id="txt_shop" style="width: 750px;" rows="2"></textarea>
        </div>
        <div>
            店铺：<input id="txt_shopname" type="text" style="width: 160px;" placeholder="输入店铺名称" />
            <input id="btn_findshop" type="button" value="查找" />
            <input id="chkclear" type="button" value="清除" />
        </div>
        <div id="shop-list" style="position: relative; height: 350px; overflow: auto;">
        </div>
    </div>
    </form>
</body>
</html>
